home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / backup / kbackup-.000 / KBackup-1.2.7.tar / KBackup / src / autodetect_src next >
Text File  |  1996-02-13  |  2KB  |  102 lines

  1.  
  2. AUTODETECT_SRC_LOADED=YES
  3.  
  4. test_tape_device_II()
  5. {
  6.     tape="$1"
  7.  
  8.     InfoBox "Testing $tape:\nrewinding..."
  9.  
  10.     my_mt -f "$tape" rewind  2>/dev/null
  11.     if [ $? = 0 ]
  12.     then
  13.         InfoBox "Testing $tape:\nwriting 1st pattern..."
  14.         ( echo "Tape device is working correctly (non-rewinding)." | \
  15.         $DD of="$tape" obs=1024 conv=sync ) 2>/dev/null 
  16.         InfoBox "Testing $tape:\nwriting 2nd pattern..."
  17.         ( echo "Tape device is incompatible with KBackup (rewinding)." | \
  18.         $DD of="$tape" obs=1024 conv=sync ) 2>/dev/null
  19.         InfoBox "Testing $tape:\nrewinding...          "
  20.         my_mt -f "$tape" rewind 2>/dev/null
  21.         InfoBox "Testing $tape:\nreading...            "
  22.         cat "$tape" | $FGREP "non-rewinding" >/dev/null 2>/dev/null
  23.         return $?
  24.     else
  25.         return 1    # error
  26.     fi
  27. }
  28.  
  29.     
  30. #
  31. #    scans system for KBackup compatible tape devices and returns
  32. #    the list of device names in $TMP/$TMPFILE2
  33. #
  34. autodetect_tape_device_II()
  35. {
  36.  
  37.     $DIALOG --title " Warning! " --yesno \
  38. "
  39. Please insert an empty tape into your drive.
  40.  
  41. This test will erase any data on the tape!
  42. Are you sure that you want to continue?" 10 50
  43.     if [ $? != 0 ]
  44.     then
  45.         return
  46.     fi
  47.  
  48.     InfoBox "Looking for devices..."
  49.     
  50.     devices=`ls /dev/[n]st* /dev/[r]mt* /dev/*tape /dev/n[r]ft* /dev/[r]ft* /dev/*mt* | sort | uniq`
  51.  
  52.     for i in $devices
  53.     do
  54.         InfoBox "Looking for: $i"
  55.         $DD if="$i" of=/dev/null bs=0 count=0 2>$TMP/$TMPFILE >/dev/null
  56.         $FGREP "No such device" $TMP/$TMPFILE >/dev/null
  57.         if [ $? != 0 ] 
  58.         then
  59.             echo "$i" >>$TMP/$TMPFILE2
  60.         fi
  61.     done
  62.  
  63.     devices=`cat $TMP/$TMPFILE2`
  64.     count=1
  65.     echo >$TMP/$TMPFILE2
  66.     tape_detected=NO
  67.     for i in $devices
  68.     do
  69.         test_tape_device_II "$i" 
  70.         
  71.         if [ $? = 0 ]
  72.         then
  73.             echo "$i ok" >>$TMP/$TMPFILE2        
  74.             tape_detected=YES
  75.         fi
  76.     done
  77. }
  78.  
  79. autodetect_tape_menu()
  80. {
  81.     if [ "$tape_detected" = "YES" ]
  82.     then
  83.         $DIALOG --title " Autodetection " --menu "
  84. These devices have been detected as being
  85. available and compatible for use with KBackup.
  86.  
  87. Please choose one from the list.
  88. " 20 60 6 `cat $TMP/$TMPFILE2` 2>$TMP/$DIALOGFILE
  89.         if [ $? = 0 ]
  90.         then
  91.             device=`cat $TMP/$DIALOGFILE`
  92.             device_type=TAPE
  93.             Configuration_changed=YES
  94.         fi
  95.     else
  96.         MessageBox "
  97. No compatible tape device found.
  98. "
  99.     fi
  100. }
  101.  
  102.